;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2021 BonfaceKilz <me@bonfacemunyoki.com>
;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
;;; Copyright © 2022 paladhammika <paladhammika@protonmail.com>
;;; Copyright © 2021, 2022 jgart <jgart@dismail.de>
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guixrus packages libervia)
  #:use-module (guix build-system copy)
  #:use-module (guix build-system python)
  #:use-module (guix build-system pyproject)
  #:use-module (guix build-system cmake)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-build)
  #:use-module (gnu packages python-check)
  #:use-module (gnu packages python-crypto)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages time)
  #:use-module (gnu packages music)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages protobuf)
  #:use-module (gnu packages crypto)
  #:use-module (gnu packages check)
  #:use-module (gnu packages sphinx)
  #:use-module ((guixrus licenses) #:prefix license:)
  #:use-module ((guixrus packages common python) #:prefix rus:))

(define-public python-x3dh
  (package
    (name "python-x3dh")
    (version "1.0.3")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "X3DH" version))
              (sha256
               (base32
                "1mamwl6spwbf5s69519r5gyck4h5jdl0jibirqd4k18nw0c5799s"))))
    (build-system python-build-system)
    (arguments '(#:tests? #f))
    (propagated-inputs (list python-cryptography python-pydantic
                             python-typing-extensions python-xeddsa))
    (home-page "https://github.com/Syndace/python-x3dh")
    (synopsis
     "A Python implementation of the Extended Triple Diffie-Hellman key agreement protocol.")
    (description
     "This package provides a Python implementation of the Extended Triple
Diffie-Hellman key agreement protocol.")
    (license license:expat)))

(define-public python-omemo
  (package
    (name "python-omemo")
    (version "1.0.2")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "OMEMO" version))
              (sha256
               (base32
                "0w5d08qmvcs9rnansy4il654ya4qg171kdj61nw4b0idsdr5aw4z"))))
    (build-system python-build-system)
    (propagated-inputs (list python-typing-extensions python-xeddsa))
    (home-page "https://github.com/Syndace/python-omemo")
    (synopsis
     "A Python implementation of the OMEMO Multi-End Message and Object Encryption protocol.")
    (description
     "This package provides a Python implementation of the OMEMO Multi-End Message and
Object Encryption protocol.")
    (license license:expat)))

(define-public python-doubleratchet
  (package
    (name "python-doubleratchet")
    (version "1.0.3")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "DoubleRatchet" version))
              (sha256
               (base32
                "0mih190gsz9afcyvx2ny92lg96fzgrxzhmp16ajznamkybx8clg2"))))
    (build-system python-build-system)
    (arguments '(#:tests? #f))
    (propagated-inputs (list python-cryptography python-pydantic
                             python-typing-extensions))
    (home-page "https://github.com/Syndace/python-doubleratchet")
    (synopsis "A Python implementation of the Double Ratchet algorithm.")
    (description
     "This package provides a Python implementation of the Double Ratchet algorithm.")
    (license license:expat)))

(define-public libxeddsa
  (package
    (name "libxeddsa")
    (version "2.0.0")
    (source
     (origin
       (method git-fetch)
       (uri
        (git-reference
         (url "https://github.com/Syndace/libxeddsa")
         (commit (string-append "v" version))))
       (sha256
        (base32 "1abhf0d2lp2sf1ykdzbifngkp2y6h6w5slbqvnbsaazzi8n7v44a"))))
    (build-system cmake-build-system)
    (arguments
      (list
        #:phases
        #~(modify-phases %standard-phases
            (replace 'install
              (lambda _
                (copy-file "../source/bin/libcombined_static.a" "libxeddsa.a")
                (install-file "libxeddsa.a"
                              (string-append #$output "/lib/")))))))
    (inputs (list libsodium))
    (synopsis "A toolkit around Curve25519 and Ed25519 key pairs, with a focus on conversion between the two.")
    (description "")
    (home-page "https://github.com/Syndace/libxeddsa")
    (license license:expat)))

(define-public python-xeddsa
  (package
    (name "python-xeddsa")
    (version "1.0.2")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "XEdDSA" version))
              (sha256
               (base32
                "05c7rxjf0js70xsyxzy4z6w60zm6g8v77v733nczaqbj1ibxjx49"))))
    (build-system python-build-system)
    (arguments '(#:tests? #f))
    (inputs (list libsodium libxeddsa))
    (propagated-inputs (list python-cffi))
    (home-page "https://github.com/Syndace/python-xeddsa")
    (synopsis "Python bindings to libxeddsa.")
    (description "Python bindings to libxeddsa.")
    (license license:expat)))

(define-public python-typing-extensions
  (package
    (name "python-typing-extensions")
    (version "4.4.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/python/typing_extensions")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0ax95a956ghhdxlp5xxhmpk4kw04jm4bxlp2fqvnv5da8a9kg7jz"))))
    (build-system python-build-system)
    (arguments
     (list
      #:tests? #f       ;requires Python's test module, not available in Guix
      #:phases
      #~(modify-phases %standard-phases
          ;; XXX: PEP 517 manual build copied from python-isort.
          (replace 'build
            (lambda _
              (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
          (replace 'check
            (lambda* (#:key tests? #:allow-other-keys)
              (when tests?
                (invoke "python" "src/test_typing_extensions.py"))))
          (replace 'install
            (lambda _
              (let ((whl (car (find-files "dist" "\\.whl$"))))
                (invoke "pip" "--no-cache-dir" "--no-input"
                        "install" "--no-deps" "--prefix" #$output whl)))))))
    (native-inputs (list python-pypa-build python-flit-core))
    (home-page "https://github.com/python/typing/typing_extensions")
    (synopsis "Experimental type hints for Python")
    (description
     "The typing_extensions module contains additional @code{typing} hints not
yet present in the of the @code{typing} standard library.
Included are implementations of:
@enumerate
@item ClassVar
@item ContextManager
@item Counter
@item DefaultDict
@item Deque
@item NewType
@item NoReturn
@item overload
@item Protocol
@item runtime
@item Text
@item Type
@item TYPE_CHECKING
@item AsyncGenerator
@end enumerate\n")
    (license license:psfl)))

(define-public python-omemo
  (package
    (name "python-omemo")
    (version "1.0.2")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "OMEMO" version))
              (sha256
               (base32
                "0w5d08qmvcs9rnansy4il654ya4qg171kdj61nw4b0idsdr5aw4z"))))
    (build-system python-build-system)
    (arguments '(#:tests? #f))
    (propagated-inputs (list python-typing-extensions python-xeddsa))
    (home-page "https://github.com/Syndace/python-omemo")
    (synopsis
     "A Python implementation of the OMEMO Multi-End Message and Object Encryption protocol.")
    (description
     "This package provides a Python implementation of the OMEMO Multi-End Message and
Object Encryption protocol.")
    (license license:expat)))

(define-public python-urwid-satext
  (package
    (name "python-urwid-satext")
    (version "0.8.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "urwid_satext" version))
              (sha256
               (base32
                "00mzdn15vn6k02j126cvbfxak75zckmmkf9ga5qv5h3hai1hpa75"))))
    (build-system python-build-system)
    (propagated-inputs (list python-urwid))
    (home-page "https://wiki.goffi.org/w/index.php/Urwid-satext")
    (synopsis "SÃ T extension widgets for Urwid")
    (description "SÃ T extension widgets for Urwid")
    (license license:lgpl2.1)))

(define-public python-cython-test-exception-raiser
  (package
    (name "python-cython-test-exception-raiser")
    (version "1.0.2")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "cython-test-exception-raiser" version))
              (sha256
               (base32
                "1amx3x4nrw5xc7s3k4jsc6yb6pnvzhlx7bpms8i84yh545ikl065"))))
    (build-system python-build-system)
    (propagated-inputs (list python-cython))
    (home-page "https://github.com/twisted/cython-test-exception-raiser")
    (synopsis "A trivial extension that just raises an exception.")
    (description
     "This package provides a trivial extension that just raises an exception.")
    (license license:expat)))

(define-public python-towncrier
  (package
    (name "python-towncrier")
    (version "22.8.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "towncrier" version))
              (sha256
               (base32
                "1js2s02kxsm7ln3z5j8c7j9k293hzm6bg0nzapxlb6w56fq3jf3x"))))
    (build-system python-build-system)
    (propagated-inputs (list python-click
                             python-click-default-group
                             python-incremental
                             python-jinja2
                             python-setuptools
                             python-tomli))
    (native-inputs (list python-packaging))
    (home-page "https://github.com/hawkowl/towncrier")
    (synopsis "Building newsfiles for your project.")
    (description "Building newsfiles for your project.")
    (license license:expat)))

(define-public python-sphinx-basic-ng
  (package
    (name "python-sphinx-basic-ng")
    (version "1.0.0b1")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "sphinx_basic_ng" version))
              (sha256
               (base32
                "1c59nmxzqxga8lc42krd1yb9k3kir0l1wy462wq2lifrrk9lndw9"))))
    (build-system python-build-system)
    (propagated-inputs (list python-sphinx))
    (home-page "https://github.com/pradyunsg/sphinx-basic-ng")
    (synopsis "A modern skeleton for Sphinx themes.")
    (description "This package provides a modern skeleton for Sphinx themes.")
    (license #f)))

(define-public python-service-identity
  (package
    (name "python-service-identity")
    (version "21.1.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "service-identity" version))
              (sha256
               (base32
                "0d4x84crbz0a17d8gi90z6zlxwm9pslc65rx0cdw2797ra360v3f"))))
    (build-system python-build-system)
    (propagated-inputs (list python-attrs
                             python-cryptography
                             python-ipaddress
                             python-pyasn1
                             python-pyasn1-modules
                             python-six))
    (native-inputs (list python-coverage
                         python-idna
                         python-pyopenssl
                         python-pytest
                         python-sphinx))
    (home-page "https://service-identity.readthedocs.io/")
    (synopsis "Service identity verification for pyOpenSSL & cryptography.")
    (description "Service identity verification for pyOpenSSL & cryptography.")
    (license license:expat)))

(define-public python-wokkel
  (package
    (name "python-wokkel")
    (version "18.0.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "wokkel" version))
              (sha256
               (base32
                "1spq44gg8gsviqx1dvlmjpgfc0wk0jpyx4ap01y2pad1ai9cw016"))))
    (build-system python-build-system)
    (arguments '(#:tests? #f))
    (propagated-inputs (list python-dateutil python-incremental python-twisted python-service-identity))
    (native-inputs (list python-coverage python-pyflakes
                         python-sphinx python-towncrier))
    (home-page "https://wokkel.ik.nu/")
    (synopsis "Twisted Jabber support library")
    (description "Twisted Jabber support library")
    (license license:expat)))

(define-public python-sat-tmp
  (package
    (name "python-sat-tmp")
    (version "0.8.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "sat_tmp" version))
              (sha256
               (base32
                "0nj6qqx8qvg5l805vh32zvjqwlg4gwckwm569wc69hhzym7dq393"))))
    (build-system python-build-system)
    (arguments '(#:tests? #f))
    (propagated-inputs (list python-wokkel python-pyopenssl))
    (home-page "https://salut-a-toi.org")
    (synopsis "Libervia temporary third party patches")
    (description "Libervia temporary third party patches")
    (license license:agpl3)))

(define-public libervia-backend
  (package
    (name "libervia-backend")
    (version "0.8.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "libervia-backend" version))
              (sha256
               (base32
                "1k2hxggplcg73qik8bax9hiycjcb9kyc6czi48ahnzm5dbda5nis"))))
    (build-system python-build-system)
    (arguments
      (list
        #:tests? #f
        #:phases
        #~(modify-phases %standard-phases
            (delete 'sanity-check)
            (add-after 'unpack 'fix-deps
              (lambda _
                (substitute* "setup.py"
                  ((".*dbus-python.*") "")
                  ((".*langid.*") "")
                  ((".*miniupnpc.*") "'miniupnpc',")
                  ((".*pygobject.*") "'pygobject',")
                  ((".*pyopenssl.*") "'pyopenssl',")
                  ((".*twisted.*tls.*") "'twisted[tls]',")
                  ((".*omemo >= 0.11.*") "'omemo',")
                  ((".*omemo-backend-signal.*") "")))))))
    (propagated-inputs (list python-babel
                             python-cairosvg
                             python-cryptography
                             python-dateutil
                             python-dbus
                             python-html2text
                             python-jinja2
                             python-lxml
                             python-markdown
                             python-miniupnpc
                             python-mutagen
                             python-netifaces
                             python-omemo
                             python-pillow
                             python-potr
                             python-progressbar2
                             python-pygments
                             python-pygobject
                             python-pyopenssl
                             python-pyxdg
                             python-pyyaml-5
                             python-sat-tmp
                             python-shortuuid
                             python-treq
                             python-twisted
                             python-urwid
                             python-urwid-satext
                             python-wokkel))
    (home-page "https://salut-a-toi.org")
    (synopsis "Libervia multipurpose and multi frontend XMPP client")
    (description "Libervia multipurpose and multi frontend XMPP client")
    (license license:agpl3)))

